package unitTests;

import static org.junit.Assert.assertTrue;

import java.io.FileInputStream;
import java.util.Scanner;

import org.junit.Before;
import org.junit.Test;

import datamodels.Conference;
import datamodels.GlobalDataStore;
/**
 * Performs JUnit testing on WrireData() 
 * @author Zach Turk
 *
 */
public class DataStoreWriteDataTest 
{
	GlobalDataStore my_data_store;
	@Before
	public void instantiate()
	{
		my_data_store = new GlobalDataStore();
	}
	
	/**
	 * Point of this test is to make sure that the file recieves some kind of input.
	 */
	@Test
	public void checkWriteDataWrites()
	{
		Conference temp = new Conference("SOMETHING");
		my_data_store.addConferenceObject(temp);
		try {
			my_data_store.writeData();
			StringBuilder text =
				new StringBuilder();
			//Scan the test conferenceinfo file
			Scanner scanner = new Scanner(new FileInputStream("src/datamodels/conferenceinfo.txt"), "UTF-8");
			try {	
				while (scanner.hasNextLine()){
					text.append(scanner.nextLine());
				}
			}
			finally{
				scanner.close();
			}
			assertTrue(text.length() > 1);
		} catch (Exception e) {
		}
	}
	

}
